package vip.xiaonuo.smzq.modular.kcl.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.kcl.entity.Dyxl;
import vip.xiaonuo.smzq.modular.kcl.service.IDyxlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 
 *
 * @author eomer
 * @since 2024-02-22
 */
@Api(tags = "")
@RestController
@RequestMapping("/kcl/dyxl")
@Validated
public class DyxlController {

    @Resource
    private IDyxlService iDyxlService;

    /**
     * 添加
     */
    @ApiOperation("添加")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Dyxl dyxl) {
        iDyxlService.save(dyxl);
        return CommonResult.ok();
    }

    /**
     * 删除
     */
    @ApiOperation("删除")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iDyxlService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑
     */
    @ApiOperation("编辑")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid Dyxl dyxl) {
        iDyxlService.updateById(dyxl);
        return CommonResult.ok();
    }

    /**
     * 分页查询
     */
    @ApiOperation("分页查询")
    @GetMapping("/list")
    public CommonResult<Page<Dyxl>> page() {
        return CommonResult.data(iDyxlService.page(new Dyxl()));
    }
}
